package com.example.demo.identity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;

import java.sql.Timestamp;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "groups")
@Entity
@Builder
public class Group {

    @Id
    @Column(name = "group_id")
    @Size(min = 35, max = 40)
    @NotEmpty
    @NotNull
    private String group_id;

    @Column(name = "group_name")
    private String group_name;

    @Column(name = "group_leader")
    private String group_leader;

    @Column(name = "create_at")
    private Timestamp create_at;

    @Column(name = "member_numbers")
    private Integer member_numbers;

    @Column(name = "group_type")
    private String group_type;

    @Column(name = "group_avatar")
    private String group_avatar;

    //    重写toString，否则sout的时候只会看到对象的内存地址
    @Override
    public String toString() {
//        Group
        return "{" +
                "group_id='" + group_id + '\'' +
                ", group_name='" + group_name + '\'' +
                ", group_leader='" + group_leader + '\'' +
                ", create_at=" + (create_at != null ? create_at.toString() : "null") +
                ", member_numbers=" + member_numbers +
                ", group_type='" + group_type + '\'' +
                '}';
    }


}
